package com.ruoyi.livesass;

import java.util.List;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.volcengine.helper.Const;
import com.volcengine.helper.Utils;
import com.volcengine.model.beans.livesaas.ActivityCreatorForm;
import com.volcengine.model.livesaas.request.AddActivityAntidirtRequest;
import com.volcengine.model.livesaas.request.AnalysisUserBehaviorPeopleV2Request;
import com.volcengine.model.livesaas.request.CommonRequest;
import com.volcengine.model.livesaas.request.CreateActivityAPIRequest;
import com.volcengine.model.livesaas.request.GetAdvertisementDataDetailAPIRequest;
import com.volcengine.model.livesaas.request.GetLiveTrafficPostPayDataRequest;
import com.volcengine.model.livesaas.request.GetLoginLivesaasStsRequest;
import com.volcengine.model.livesaas.request.GetPageWatchDataAPIV2Request;
import com.volcengine.model.livesaas.request.GetStreamsAPIRequest;
import com.volcengine.model.livesaas.request.GetUserBehaviorListRequest;
import com.volcengine.model.livesaas.request.GetUserBehaviorListRequestAPIV2;
import com.volcengine.model.livesaas.request.ListActivityAPIRequest;
import com.volcengine.model.livesaas.request.SilenceUserAPIRequest;
import com.volcengine.model.livesaas.request.UpdateLiveChannelConfigRequest;
import com.volcengine.model.livesaas.response.AnalysisUserBehaviorPeopleV2Response;
import com.volcengine.model.livesaas.response.CommonResponse;
import com.volcengine.model.livesaas.response.CommonStatusResponse;
import com.volcengine.model.livesaas.response.CreateActivityAPIResponse;
import com.volcengine.model.livesaas.response.GetActivityAPIResponse;
import com.volcengine.model.livesaas.response.GetAdvertisementDataDetailAPIResponse;
import com.volcengine.model.livesaas.response.GetLiveTrafficPostPayDataResponse;
import com.volcengine.model.livesaas.response.GetLoginLivesaasStsResponse;
import com.volcengine.model.livesaas.response.GetPageWatchDataAPIV2Response;
import com.volcengine.model.livesaas.response.GetPageWatchDataAPIV2Response.PageClicksFormAPI;
import com.volcengine.model.livesaas.response.GetRealTimeOnlineNumberAPIResponse;
import com.volcengine.model.livesaas.response.GetStreamsAPIResponse;
import com.volcengine.model.livesaas.response.GetStreamsAPIResponse.GetStreamsAPILineDetail;
import com.volcengine.model.livesaas.response.GetUserBehaviorListResponseAPIV2;
import com.volcengine.model.livesaas.response.ListActivityAPIResponse;
import com.volcengine.model.livesaas.response.ListAnActivityStartAndEndTimeAPIResponse;
import com.volcengine.model.livesaas.response.ListLiveChannelConfigResponse;
import com.volcengine.model.livesaas.response.ListLiveChannelConfigResponse.ListLiveChannelConfigResponseBody;
import com.volcengine.model.livesaas.response.UpdateLiveChannelConfigResponse;
import com.volcengine.service.livesaas.LivesaasService;
import com.volcengine.service.livesaas.impl.LivesaasServiceImpl;

import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.digest.DigestUtil;

/**
 * @ClassName: LiveVideoService
 * @Description: TODO(直播相关)
 * @author 晏大兵
 * @date 2025年2月10日 上午11:13:23
 */
@Component
@Order(0)
public class LiveVideoService implements ApplicationRunner {
	
	private static final Logger LOG = LoggerFactory.getLogger(LiveVideoService.class);

	public LivesaasService livesaasService;
	
	//@Value("${custom.hsSubUserName}")
	//private String hsSubUserName;

	@Override
	public void run(ApplicationArguments args) throws Exception {
		livesaasService = LivesaasServiceImpl.getInstance();
		livesaasService.setAccessKey("AKLTZDVmMmY3YzcxNTcxNDYwMWFlOTgwMTE1NTBhYjI2Yjg");
		livesaasService.setSecretKey("WkdWbE1HUXdZbVpoTmpaaE5ETmpNV0V6TTJFMk9XVmtObU16TVdZNU56SQ==");
		
		
		/*
		System.out.println("LiveVideoService 初始化完成.");
		//System.out.println(JSONObject.toJSONString(getPageWatchData(1827191606928569L)));
		GetUserBehaviorListRequestAPIV2 apiRequest = new GetUserBehaviorListRequestAPIV2();
		apiRequest.setActivityId(1827727218377756l);
		apiRequest.setPageNo(1l);
		apiRequest.setPageItemCount(500l);
		apiRequest.setPlayStatus(1); //只查询观看直播的时长
		//多次出入直播间合并为一条数据
		apiRequest.setIsMergeUserId(1);
		apiRequest.setUserId(1827470651547690l);
		//apiRequest.setIsMerge(1);
		
		GetUserBehaviorListResponseAPIV2 apiResponse = livesaasService.ListUserBehaviorDataAPIV2(apiRequest);
		//LOG.debug("获取直播间用户行为数据 | " + JSONObject.toJSONString(apiResponse));
		
		System.out.println("获取直播间用户行为数据 | " + JSONObject.toJSONString(apiResponse));
		*/
		
	}

	/**
	* @Title: getSign 
	* @Description: TODO(生成Sign) 
	* @param @param zbjid
	* @param @param userId
	* @param @param timestamp
	* @param @return    设定文件 
	* @return String    返回类型 
	* @throws
	 */
	public  String getSign(long zbjid,long userId,long timestamp){
		String  secret_key = "2ip::il22.";// livesaasService.getSecretKey();
		String hw = secret_key+""+userId+""+timestamp;
		String sign = DigestUtil.md5Hex(hw);
        return  sign;
	}
	
	public  String getSignDp(long zbjid,String userId,long timestamp){
		String  secret_key = "2ip::il22.";// livesaasService.getSecretKey();
		String hw = secret_key+""+userId+""+timestamp;
		String sign = DigestUtil.md5Hex(hw);
        return  sign;
	}
	 
	/**
	 * 
	 * @Title: getStreamsInfo
	 * @Description: TODO(获取直播间推流信息)
	 * @param PageNo        分页查询页码 最大支持返回 10,000
	 * @param PageItemCount 分页查询数量 最大支持返回 10,000
	 * @param userName 子账户名称
	 * @param @return
	 * @param @throws       Exception 设定文件
	 * @return GetActivityAPIResponse 返回类型
	 * @throws
	 */
	public GetStreamsAPILineDetail getStreamsInfo(long zbjid) throws Exception {
		
		GetStreamsAPIRequest getStreamsAPIRequest = new GetStreamsAPIRequest();
		getStreamsAPIRequest.setActivityId(zbjid);
		
		GetStreamsAPIResponse getStreamsAPIResponse = livesaasService.getStreamsAPI(getStreamsAPIRequest);
		
		
		LOG.debug("获取直播推流和拉流信息 | " + JSONObject.toJSONString(getStreamsAPIResponse));
		
		//默认获取第一1个数据
		if(getStreamsAPIResponse.getResult().getLineDetails().size() > 0) {
			//.getMainPushInfo();
			GetStreamsAPILineDetail getStreamsAPILineDetail = getStreamsAPIResponse.getResult().getLineDetails().get(0);
			
			return getStreamsAPILineDetail;
		}
		
		return null;
	}
	
	/**
	 * 
	 * @Title: listActivity
	 * @Description: TODO(获取直播列表)
	 * @param PageNo        分页查询页码 最大支持返回 10,000
	 * @param PageItemCount 分页查询数量 最大支持返回 10,000
	 * @param userName 子账户名称
	 * @param @return
	 * @param @throws       Exception 设定文件
	 * @return GetActivityAPIResponse 返回类型
	 * @throws
	 */
	public ListActivityAPIResponse listActivity(int pageNo, int pageItemCount, String userName) throws Exception {
		int status = 0;
		String sortBy = "LiveTime";
		String sortOrder = "Desc";
		ListActivityAPIResponse listActivityAPIResponse = this.listActivity(pageNo, pageItemCount, userName, status, sortBy, sortOrder, 0);
		return listActivityAPIResponse;
	}
	

	
	public ListActivityAPIResponse listActivity(int pageNo, int pageItemCount, String userName, int status, String sortBy, String sortOrder, long liveTime) throws Exception {
		ListActivityAPIRequest listActivityAPIRequest = new ListActivityAPIRequest();
		listActivityAPIRequest.setPageNo(pageNo);
		listActivityAPIRequest.setPageItemCount(pageItemCount);
		listActivityAPIRequest.setFollowerUserName(userName);
		listActivityAPIRequest.setStatus(status);
		listActivityAPIRequest.setSortBy(sortBy);
		listActivityAPIRequest.setSortOrder(sortOrder);
		
		if(liveTime != 0) {
			listActivityAPIRequest.setLiveTime(liveTime);
		}
		
		ListActivityAPIResponse listActivityAPIResponse = livesaasService.listActivityAPI(listActivityAPIRequest);
		
		
		LOG.debug("获取直播间信息: " + JSONObject.toJSONString(listActivityAPIResponse));
		
		return listActivityAPIResponse;
	}
	
	

	/**
	 * 
	 * @Title: getActivityInfo
	 * @Description: TODO(获取直播间信息)
	 * @param zbjid   直播间ID
	 * @param @return
	 * @param @throws Exception 设定文件
	 * @return CreateActivityAPIResponse 返回类型
	 * @throws
	 */
	public GetActivityAPIResponse getActivityInfo(long zbjid) throws Exception {
		CommonRequest commonAPIRequest = new CommonRequest();
		commonAPIRequest.setActivityId(zbjid);

		GetActivityAPIResponse getActivityAPIResponse = livesaasService.getActivityAPI(commonAPIRequest);

		return getActivityAPIResponse;

	}

	/**
	 * @Title: createActivity
	 * @Description: TODO(创建直播间)
	 * @param fjmc    房间名称
	 * @param zzhid   子账户id
	 * @param zbkssj  直播开始时间
	 * @param fm      封面图片
	 * @param @return 设定文件
	 * @return GetActivityAPIResponse 返回类型
	 * @throws Exception
	 * @throws
	 */
	public CreateActivityAPIResponse createActivity(String fjmc, String zzhid, long zbkssj, String fmUrl)
			throws Exception {
		// VerticalCoverImage
		CreateActivityAPIRequest caar = new CreateActivityAPIRequest();
		caar.setName(fjmc);
		caar.setCreatorName(zzhid);
		if(zbkssj != 0) {
			caar.setLiveTime(zbkssj);
		}
		
		if(!StrUtil.isEmptyIfStr(fmUrl)) {
			caar.setVerticalCoverImage(fmUrl);
		}
		
		
		// 普通延迟
		caar.setLiveMode(2);
		// 直播布局 纯视频
		caar.setLiveLayout(2);

		// 创建直播间
		CreateActivityAPIResponse createActivityAPIResponse = livesaasService.createActivityAPIV2(caar);
		long activityId = createActivityAPIResponse.getResult().getActivityId();
		//1823659621925915
		LOG.debug(fjmc + " | 创建完成 | " + JSONObject.toJSONString(createActivityAPIResponse));
		LOG.debug(fjmc + " | activityId | " + activityId);
		

		// 这里默认更新直播间为只能移动端观看
		// UpdateActivityBasicConfigAPI
		/*
		UpdateBasicConfigAPIRequest updateBasicConfigAPIRequest = new UpdateBasicConfigAPIRequest();
		updateBasicConfigAPIRequest.setActivityId(activityId);
		updateBasicConfigAPIRequest.setIsPageLimitEnable(1);
		updateBasicConfigAPIRequest.setPageLimitType("mobile");
		livesaasService.updateActivityBasicConfigAPI(updateBasicConfigAPIRequest);*/

		//更新频道
		updateLiveChannelConfig(activityId);
		
		return createActivityAPIResponse;

	}
	
	
	/**
	 * 
	 * @Title: deleteActivity
	 * @Description: TODO(删除直播间)
	 * @param @return
	 * @param @throws       Exception 设定文件
	 * @return GetActivityAPIResponse 返回类型
	 * @throws
	 */
	public CommonResponse deleteActivity(long zbjid) throws Exception {
		CommonRequest commonRequest = new CommonRequest();
		commonRequest.setActivityId(zbjid);
		CommonResponse commonResponse = livesaasService.deleteActivityAPI(commonRequest);
		return commonResponse;
	}

	/**
	 * @Title: silenceUserAPI
	 * @Description: TODO(将直播间中某个用户禁言)
	 * @param @param  zbjid 直播间ID
	 * @param @param  userId 用户ID
	 * @param @param  status true：禁言； false：取消禁言
	 * @param @return
	 * @param @throws Exception 设定文件
	 * @return ListActivityAPIResponse 返回类型
	 * @throws
	 */
	public CommonStatusResponse silenceUserAPI(long zbjid, long userid, boolean status) throws Exception {
		SilenceUserAPIRequest silenceUserAPIRequest = new SilenceUserAPIRequest();
		silenceUserAPIRequest.setActivityId(zbjid);
		silenceUserAPIRequest.setUserId(userid);
		silenceUserAPIRequest.setStatus(status);
		return livesaasService.silenceUserAPI(silenceUserAPIRequest);
	}
	
	
	
	
	/**
	 * 
	* @Title: updateLiveChannelConfig 
	* @Description: TODO(更新直播间通道清晰度) 
	* @param @param activityId    直播间ID
	* @return void    返回类型 
	 * @throws Exception 
	* @throws
	 */
	private void updateLiveChannelConfig(long activityId) throws Exception {
		// 首先获取到频道ID
		//ListLiveChannelConfig
		CommonRequest listLiveChannelConfigRequest = new CommonRequest();
		listLiveChannelConfigRequest.setActivityId(activityId);
		ListLiveChannelConfigResponse listLiveChannelConfigResponse = livesaasService.listLiveChannelConfig(listLiveChannelConfigRequest);
		
		LOG.debug("频道信息 | " + JSONObject.toJSONString(listLiveChannelConfigResponse));
		
		ListLiveChannelConfigResponseBody liveChannelConfigResponseBody = listLiveChannelConfigResponse.getResult().get(0);
		
		
		UpdateLiveChannelConfigRequest updateLiveChannelConfigRequest = new UpdateLiveChannelConfigRequest();
		String resolutionSd = "sd";
		List<String> resolutionList = Lists.newArrayList();
		resolutionList.add(resolutionSd);
		updateLiveChannelConfigRequest.setLineId(liveChannelConfigResponseBody.getLineId());
		updateLiveChannelConfigRequest.setActivityId(activityId);
		updateLiveChannelConfigRequest.setResolution(resolutionList);
		updateLiveChannelConfigRequest.setMobileDefaultResolution(resolutionSd);
		updateLiveChannelConfigRequest.setPCDefaultResolution(resolutionSd);

		UpdateLiveChannelConfigResponse updateLiveChannelConfigResponse = livesaasService.updateLiveChannelConfig(updateLiveChannelConfigRequest);
	}
	

	
	/**
	 * 
	* @Title: getLiveTrafficPostPayData 
	* @Description: TODO(根据一组直播间ID获取直播流量数据) 
	* @param @param zbjids 一组直播ID 与 subUserName 只能选其一
	* @param @param subUserName 创建直播间得用户ID
	* @param @param startDay 开始时间不能与结束时间大于30天
	* @param @param endDay 结束时间不能大于等于今日
	* @param @return
	* @param @throws Exception    设定文件 
	* @return GetLiveTrafficPostPayDataResponse    返回类型 
	* @throws
	 */
	public GetLiveTrafficPostPayDataResponse getLiveTrafficPostPayData(List<Long> zbjids, String subUserName, String startDay, String endDay) throws Exception {
		GetLiveTrafficPostPayDataRequest getLiveTrafficPostPayDataRequest = new GetLiveTrafficPostPayDataRequest();
		
		if(null != zbjids) {
			getLiveTrafficPostPayDataRequest.setActivityIds(zbjids);
		}
		
		if(null != subUserName && !"".equals(subUserName)) {
			ActivityCreatorForm activityCreatorForm = new ActivityCreatorForm();
			activityCreatorForm.setIsMainAccount(false);
			activityCreatorForm.setSubAccountName(subUserName);
			getLiveTrafficPostPayDataRequest.setActivityCreator(activityCreatorForm);
		}
		
		getLiveTrafficPostPayDataRequest.setStartDay(startDay);
		getLiveTrafficPostPayDataRequest.setEndDay(endDay);
		
		
		LOG.debug("获取直播流量数据 ActivityIds | " + JSONObject.toJSONString(zbjids));
		
		
		GetLiveTrafficPostPayDataResponse getLiveTrafficPostPayDataResponse = livesaasService.getLiveTrafficPostPayData(getLiveTrafficPostPayDataRequest);
		LOG.debug("获取直播流量数据 | " + JSONObject.toJSONString(getLiveTrafficPostPayDataResponse));
		
		return getLiveTrafficPostPayDataResponse;
	}
	
	
	
	/**
	* @Title: getPageWatchData 
	* @Description: TODO(获取直播间用户观看数据) 
	* @param @param zbjid
	* @param @throws Exception    设定文件 
	* @return void    返回类型 
	* @throws
	* 
	* 		"AvgNumber": 1.25,  平均在线人数
			"AvgTime": 2.25, 平均观看时长
			"PCU": 3, 最高在线人数
			"PV": 5, 总观看人次
			"TotalTime": 9, 总观看时长(所有人合并后的时长)
			"UV": 4  总观看人数（相同设备合并后的数据）
	 */
	public PageClicksFormAPI getPageWatchData(long zbjid) throws Exception {
		
		GetPageWatchDataAPIV2Request getPageWatchDataAPIV2Request = new GetPageWatchDataAPIV2Request();
		getPageWatchDataAPIV2Request.setActivityId(zbjid);
		getPageWatchDataAPIV2Request.setPlayStatus(11);
		
		GetPageWatchDataAPIV2Response getPageWatchDataAPIV2Response = livesaasService.getPageWatchDataAPIV2(getPageWatchDataAPIV2Request);
		PageClicksFormAPI pageClicksFormAPI = getPageWatchDataAPIV2Response.getResult().getPageClicks();
		
		//LOG.debug("获取直播间用户观看数据 | " + JSONObject.toJSONString(getPageWatchDataAPIV2Response));
		
		LOG.debug("获取直播间用户观看数据 | " + zbjid);
		
		return pageClicksFormAPI;
		
	}
	
	
	
	/**
	* @Title: getUserBehaviorDataList 
	* @Description: TODO(根据直播间ID获取用户行为数据) 
	* @param @param zjbid
	* @param @throws Exception    设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public GetUserBehaviorListResponseAPIV2 getUserBehaviorDataList(long zjbid, long pageNo, long pageCount) throws Exception {
		
		GetUserBehaviorListRequestAPIV2 apiRequest = new GetUserBehaviorListRequestAPIV2();
		apiRequest.setActivityId(zjbid);
		apiRequest.setPageNo(pageNo);
		apiRequest.setPageItemCount(pageCount);
		apiRequest.setPlayStatus(1); //只查询观看直播的时长
		//多次出入直播间合并为一条数据
		apiRequest.setIsMergeUserId(1);
		//apiRequest.setIsMerge(1);
		
		GetUserBehaviorListResponseAPIV2 apiResponse = livesaasService.ListUserBehaviorDataAPIV2(apiRequest);
		
		//LOG.debug("获取直播间用户行为数据 | " + JSONObject.toJSONString(apiResponse));
		
		LOG.debug("获取直播间用户行为数据 | " + zjbid);
		
		return apiResponse;
	}
	

	/**
	* @Title: getActivityStartAndEndTime 
	* @Description: TODO(获取直播间的开关播时间) 
	* @param @param zjbid
	* @param @throws Exception    设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public ListAnActivityStartAndEndTimeAPIResponse getActivityStartAndEndTime(long zjbid) throws Exception {
		CommonRequest commonRequest = new CommonRequest();
		commonRequest.setActivityId(zjbid);
		ListAnActivityStartAndEndTimeAPIResponse apiResponse = livesaasService.listAnActivityStartAndEndTimeAPI(commonRequest);
		LOG.debug("获取直播间的开关播时间 | " + JSONObject.toJSONString(apiResponse));
		return apiResponse;
	}
	
	
	/**
	* @Title: getAnalysisUserBehaviorPeople 
	* @Description: TODO(根据传入的时间范围返回不同观看时长的人数) 
	* @param @param zjbid
	* @param @throws Exception    设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public AnalysisUserBehaviorPeopleV2Response getAnalysisUserBehaviorPeople(long zjbid, long bfb) throws Exception {
		
		AnalysisUserBehaviorPeopleV2Request analysisUserBehaviorPeopleV2Request = new AnalysisUserBehaviorPeopleV2Request();
		analysisUserBehaviorPeopleV2Request.setActivityId(zjbid);
		analysisUserBehaviorPeopleV2Request.setTotalTime(Long.valueOf(60*100));
		analysisUserBehaviorPeopleV2Request.setPercentage(bfb);
		analysisUserBehaviorPeopleV2Request.setPlayStatus(1); //只查询观看直播的用户
		analysisUserBehaviorPeopleV2Request.setIsMergeUserId(1); //多次进入和多设备合并为1个用户
		
		AnalysisUserBehaviorPeopleV2Response apiResponse = livesaasService.analysisUserBehaviorPeopleV2(analysisUserBehaviorPeopleV2Request);
		
		LOG.debug("获取直播间不同观看时长的人数bfb["+bfb+"] | " + JSONObject.toJSONString(apiResponse));
		
		return apiResponse;
	}
	
	/**
	* @Title: getAnalysisUserBehaviorPeople 
	* @Description: TODO(根据传入的时间范围返回不同观看时长的人数) 
	* @param @param zjbid
	* @param @throws Exception    设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public AnalysisUserBehaviorPeopleV2Response getAnalysisUserBehaviorPeople(long zjbid, long startTime, long endTime) throws Exception {
		
		AnalysisUserBehaviorPeopleV2Request analysisUserBehaviorPeopleV2Request = new AnalysisUserBehaviorPeopleV2Request();
		analysisUserBehaviorPeopleV2Request.setActivityId(zjbid);
		analysisUserBehaviorPeopleV2Request.setStartTime(startTime);
		analysisUserBehaviorPeopleV2Request.setEndTime(endTime);
		analysisUserBehaviorPeopleV2Request.setPercentage(100l);
		analysisUserBehaviorPeopleV2Request.setPlayStatus(1); //只查询观看直播的用户
		analysisUserBehaviorPeopleV2Request.setIsMergeUserId(1); //多次进入和多设备合并为1个用户
		
		AnalysisUserBehaviorPeopleV2Response apiResponse = livesaasService.analysisUserBehaviorPeopleV2(analysisUserBehaviorPeopleV2Request);
		
		LOG.debug("获取直播间不同观看时长的人数totalTime["+(endTime-startTime)+"] | " + JSONObject.toJSONString(apiResponse));
		
		return apiResponse;
	}
	
	
	/**
	* @Title: getLivesaasSts 
	* @Description: TODO(根据子账户获取授权KEY) 
	* @param @param subname
	* @param @throws Exception    设定文件 
	* @return void    返回类型 
	* @throws
	 */
	public GetLoginLivesaasStsResponse getLivesaasSts(String subname) throws Exception {
		
		GetLoginLivesaasStsRequest getLoginLivesaasStsRequest = new GetLoginLivesaasStsRequest();
		getLoginLivesaasStsRequest.setDurationSeconds(10080);
		getLoginLivesaasStsRequest.setFollowerUserName(subname);
		
		GetLoginLivesaasStsResponse getLoginLivesaasStsResponse = livesaasService.getLoginLivesaasSts(getLoginLivesaasStsRequest);
		
		return getLoginLivesaasStsResponse;
	}
	
	
	
	/**
	* @Title: getRealTimeOnlineNumber 
	* @Description: TODO(获取直播间实时在线人数) 
	* @param @param zjbid
	* @param @return
	* @param @throws Exception    设定文件 
	* @return GetRealTimeOnlineNumberAPIResponse    返回类型 
	* @throws
	 */
	public GetRealTimeOnlineNumberAPIResponse getRealTimeOnlineNumber(long zjbid) throws Exception {
		CommonRequest commonRequest = new CommonRequest();
		commonRequest.setActivityId(zjbid);
		GetRealTimeOnlineNumberAPIResponse getRealTimeOnlineNumberAPIResponse = livesaasService.getRealTimeOnlineNumberAPI(commonRequest);
		return getRealTimeOnlineNumberAPIResponse;
	}
	
	
	/**
	* @Title: getRealTimeOnlineNumber 
	* @Description: TODO(获取直播间实商品点击数) 
	* @param @param zjbid
	* @param @return
	* @param @throws Exception    设定文件 
	* @return GetRealTimeOnlineNumberAPIResponse    返回类型 
	* @throws
	 */
	public GetAdvertisementDataDetailAPIResponse getAdvertisementData(long zjbid) throws Exception {
		
		GetAdvertisementDataDetailAPIRequest request = new GetAdvertisementDataDetailAPIRequest();
		request.setActivityId(zjbid);
		request.setPageSize(1);
		request.setPageNumber(1);
		request.setPageAdvertiseTypes("4");//商品卡片
		
		GetAdvertisementDataDetailAPIResponse response = livesaasService.getAdvertisementDataDetailAPI(request);
		System.out.println(JSONObject.toJSONString(response));
		return response;
	}
	
	
	public void addActivityAntidirtAPI(Long zbjjlid, List<String> wordList) throws Exception {
		if(wordList!=null && wordList.size()>0 && zbjjlid!=null) {
			AddActivityAntidirtRequest addActivityAntidirtRequest = new AddActivityAntidirtRequest();
			addActivityAntidirtRequest.setActivityId(zbjjlid);
			addActivityAntidirtRequest.setWordList(wordList);
			CommonStatusResponse response =	livesaasService.addActivityAntidirtAPI(addActivityAntidirtRequest);
		}
		
	}
	
	
	
	
	
}
